package monitor

import (
	"github.com/shirou/gopsutil/cpu"
	"github.com/shirou/gopsutil/disk"
	"github.com/shirou/gopsutil/host"
	"github.com/shirou/gopsutil/load"
	"github.com/shirou/gopsutil/mem"
	"github.com/shirou/gopsutil/net"
	"github.com/shirou/gopsutil/process"
	"time"
)

func GetHostInformation() *host.InfoStat {
	info, _ := host.Info()
	return info
}

func GetDiskInformation() []disk.PartitionStat {
	info, _ := disk.Partitions(true)
	return info
}

func GetDiskUsage(paths []string) []*disk.UsageStat {
	var redata []*disk.UsageStat
	for _, k := range paths {
		re, _ := disk.Usage(k)
		redata = append(redata, re)
	}
	return redata
}

func GetCpuLoad() *load.AvgStat {
	info, _ := load.Avg()
	return info
}

func GetMemoryInformation() *mem.VirtualMemoryStat {
	info, _ := mem.VirtualMemory()
	return info
}

func GetNetWorkFlow() []net.IOCountersStat {
	info, _ := net.IOCounters(true)
	return info
}

func GetNetWorkInformation() []net.InterfaceStat {
	info, _ := net.Interfaces()
	return info
}

func GetPids() int {
	pids, _ := process.Pids()
	return len(pids)
}

func GetCpuInformation() []cpu.InfoStat {
	info, _ := cpu.Info()
	return info
}

func GetCpuUsed() []float64 {
	info, _ := cpu.Percent(time.Second, false)
	return info
}
